package com.etc.controller;
import com.etc.entity.User;
import com.etc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author
 * @Description
 * @Date 2021/1/4  17:01
 **/
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService iUserService;
    @GetMapping("/findAll")
    public List<User> getUser() {
        List<User> all = iUserService.findAll();
        return all;
    }
    @GetMapping("/add")
    public Integer addUser(User user) {
        Integer add = iUserService.add(user);
        return add;
    }
    //@DeleteMapping("/delete")
    @GetMapping("/delete")
    public Integer deleteById(Integer uId) {
        Integer integer = iUserService.deleteById(uId);
        return integer;
    }
    //    @PutMapping("/update")
    @GetMapping("/update")
    public Integer update(User user){
        Integer update = iUserService.update(user);
        return  update;
    }
    @GetMapping("/getUBI/{uId}")
    public User getUserById(@PathVariable(value = "uId") int uId) {
        User byId = iUserService.getById(uId);
        return byId;
    }


}
